package com.example.myapplication.homepage;


import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.example.myapplication.R;
import com.example.myapplication.homepage.BaiYiBuTieActivity;
import com.example.myapplication.homepage.HuoDongRiLiActivity;
import com.example.myapplication.homepage.TaoBaoMiaoShaActivity;
import com.example.myapplication.homepage.TaoBaoZhiBoActivity;
import com.example.myapplication.homepage.TaoPiaoPiaoActivity;


public class ShouYeFragment extends Fragment {
    private LinearLayout llbaiyibutie, lltaobaomiaosha, lltaobaozhibo, lltaopiaopiao,
            llhuodongrili, lllianlianxiao, llhongbaoqiandao, llbabanongchang,
            lltiantianlingqian, lljinbishaung11;

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        initView(view);
        setListeners();
    }

    private void initView(View view) {
        llbaiyibutie = view.findViewById(R.id.btn_baiyibutie);
        lltaobaomiaosha = view.findViewById(R.id.btn_taobaomiaosha);
        lltaobaozhibo = view.findViewById(R.id.btn_taobaozhibo); // 假设这是正确的ID
        lltaopiaopiao = view.findViewById(R.id.btn_taopiaopiao); // 假设这是正确的ID
        llhuodongrili = view.findViewById(R.id.btn_huodongrili); // 假设这是正确的ID
        lllianlianxiao = view.findViewById(R.id.btn_lianlianxiao); // 假设这是正确的ID
        llhongbaoqiandao = view.findViewById(R.id.btn_hongbaoqiandao); // 假设这是正确的ID
        llbabanongchang = view.findViewById(R.id.btn_babanongchang); // 假设这是正确的ID
        lltiantianlingqian = view.findViewById(R.id.btn_tiantianlingqian); // 假设这是正确的ID
        lljinbishaung11 = view.findViewById(R.id.btn_jinbishuang11); // 假设这是正确的ID
    }

    private void setListeners() {
        llbaiyibutie.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), BaiYiBuTieActivity.class);
                startActivity(intent);
            }
        });

        lltaobaozhibo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TaoBaoZhiBoActivity.class);
                startActivity(intent);
            }
        });
        lltaobaomiaosha.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TaoBaoMiaoShaActivity.class);
                startActivity(intent);
            }
        });
        lltaopiaopiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), TaoPiaoPiaoActivity.class);
                startActivity(intent);
            }
        });
        llhuodongrili.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(getActivity(), HuoDongRiLiActivity.class);
                startActivity(intent);
            }
        });
        lllianlianxiao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("连连消正在建设");

            }
        });
        llhongbaoqiandao.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("红包签到正在建设");

            }
        });
        llbabanongchang.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("芭芭农场正在建设");

            }
        });
        lltiantianlingqian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("天天领钱正在建设");

            }
        });
        lljinbishaung11.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showToast("金币双11正在建设");

            }
        });
    }

    private void showToast(String message) {
        Context context = getContext();
        Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_shouye, container, false);
    }
}